package com.iqik.filter.utils;

import org.apache.dubbo.rpc.RpcContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.servlet.ServletRequest;

public class DubboTraffic {

    private static final Logger LOGGER = LoggerFactory.getLogger(DubboTraffic.class);

    public static void saveFrom(ServletRequest request) {
        LOGGER.info("Set rpc context attachment address: {}:{}", request.getRemoteHost(), request.getRemotePort());
        RpcContext.getContext().setAttachment("address", String.format("%s:%d", request.getRemoteHost(), request.getRemotePort()));
    }

}
